home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-06-26 | 3.9 KB | 87 lines | [TEXT/GEOL] |
- Item 3347047 21-June-89 19:23
-
- From: ROSENSTEIN1 Rosenstein, Larry
-
- To: D2086 Efficient Field Svc, C Faith, PRT
-
- cc: MACAPP.TECH$ MACAPP Tech
-
- Sub: re Object Pascal
-
- You want a way for TAbstract.Foo to tell whether the caller overrided Foo or
- not. My idea was to move the functionality from TAbstract.Foo to
- TAbstract.Bar, and make TAbstract.Foo signal an error.
-
- In the subclass TConcrete, TConcrete.Foo would call Bar to get the appropriate
- functionality. This is not desirable alternative, but I don't know of any
- lanuguage that provides the capability you want.
-
- It seems to me that if a method has code in it, then that code should perform
- some task. It shouldn't perform half of a task and require someone to override
- the method to perform the other half. I think you should decompose the thing
- you want to do into finer parts, and decide which can be implemented
- generically and which need to be implemented for a specific subclass (e.g. in a
- specific database).
-
-
- For example, it may make sense for TAbstract.Foo call another method, and make
- that method the one that signals an error if it is not overridden. This sort
- of turns the problem around: instead of letting the subclass decide when to
- invoke the superclass' functionality, the superclass determines when to invoke
- the subclass'.
-
- >I cannot have the method DoSomething do anything in TAbstract and still warn
- >that it should be overriden. (Maybe this is not desirable?)
-
- You can't do this without digging through the object code at runtime, and I
- think that is undesirable.
-
- re: method dispatching
-
- Whether or not a particular JSR uses A5-relative addressing (ie, requires a
- jump table entry) or PC-relative addressing (doesn't), does depend on whether
- the caller and the callee are in the same segment. This decision is made by
- the linker, and takes into account segmentation changes you might do on the
- link command line. (The jump table is involved in cross-segment references, to
- load the segment if necessary and because the target address can change if the
- segment moves around.)
-
- A method call is totally different from a normal procedure call. Conceptually,
- all method calls result in a table lookup to find the address of the piece of
- code.
-
- If you were to dump the output of the Pascal compiler, you would find that a
- method call is simply a JSR to a routine associated with the method. This
- routine contains a call to the method dispatcher followed by the table of
- implementations for that method. The dispatcher finds the right method to call
- and jumps to it.
-
- Normally the method tables are stored in a separate segment so that each method
- call requires a jump table for the cross-segment reference. The jump to the
- actual code also goes through the jump table for a couple of reasons. First,
- it means the method dispatcher doesn't have to load segments itself. Second,
- the method tables are smaller because they only need to contain the offset into
- the jump table, rather than a segment number and offset into the segment.
-
- When a method is optimized, calls are redirected to the actual method, rather
- than to the method table. At this point, the situation is the same as that of
- a regular procedure, and the call with be PC-relative if the caller and callee
- end up in the same segment.
-
- Remapping the method tables to eliminate the initial jump table entry would not
- provide a significant performance improvement. The method tables are always
- loaded, so this simply involves an extra JMP instruction. This is small
- compared to the time needed to look up the method and execute it.
-
- My initial thought was that the runtime implementation depends on having the
- method tables in a different segment, but I can't remember exactly why so
- perhaps it can be done. Unfortunately, I don't think there is an MPW tool that
- will remap the segment for an individual routine.
-
- Larry
-
-
-
-
-
-